# coding: utf-8

from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, SelectField
from wtforms.validators import DataRequired


class BookAddForm(FlaskForm):
    name = StringField('书名', validators=[DataRequired()])
    book_type_id = StringField('书籍类型', validators=[DataRequired()])
    author = StringField('作者', validators=[DataRequired()])
    price = StringField('价格', validators=[DataRequired()])
    available_count = StringField('库存', validators=[DataRequired()])
    is_active = SelectField('是否上架',
                            choices=[('1', '是'), ('0', '否')], 
                            coerce=int,
                            validators=[DataRequired(message="是否上架为必填项")],
                            )
    submit = SubmitField('添加')


class BookEditForm(BookAddForm):
    submit = SubmitField('编辑')
